home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 8926 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: dildog.lgc.com!usenet
  2. From: Glenn Carr <gcarr@tulsa.lgc.com>
  3. Newsgroups: gnu.gcc.help,comp.lang.c
  4. Subject: Re: gcc 2.7.2 warning: left-hand operand of comma expression has no effect
  5. Date: Wed, 06 Mar 1996 14:13:28 -0600
  6. Organization: Landmark Graphics
  7. Message-ID: <313DF1E8.7DE1@tulsa.lgc.com>
  8. References: <313DEA09.237C@tulsa.lgc.com>
  9. NNTP-Posting-Host: 134.132.131.47
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0 (X11; I; AIX 1)
  14.  
  15. Glenn Carr wrote:
  16.  
  17. > static char    *rcsid = "$Id: cfgopen.c,v 1.4 1995/12/11 16:04:35 gcarr Exp $";
  18. > #if __GNUC__ == 2
  19. > #define USE(var) static void * use_##var = (&use_##var, (void *) &var)
  20. > USE(rcsid);
  21. > #endif
  22.  
  23. Fixed this by adding (void) before &use_##var...
  24. #define USE(var) static void * use_##var = ((void)&use_##var, (void *) &var)
  25.  
  26. > We also have another frequent occurrence of this problem.  We have defined a 'Dbg'
  27. > macro as follows...
  28. > void            _DbgLog1(char *pszFile, int nLine, char *pszTimeFmt);
  29. > void            _DbgLog2(char *pszFmt,...);
  30. > #ifdef DEBUG
  31. > #define Dbg    _DbgLog1(__FILE__, __LINE__, DBGLOG_TIMEFMT), _DbgLog2
  32. > #else
  33. > #define Dbg    (void)
  34. > #endif /* DEBUG */
  35.  
  36. Fixed _part_ of this problem by adding (void) before _DbgLog1...
  37. #define DbgLog ((void)_DbgLog1(__FILE__, __LINE__, DBGLOG_TIMEFMT), _DbgLog2)
  38.  
  39. ...but only when DEBUG is defined.  When DEBUG is not defined, the preprocessed output
  40. looks like this...
  41.  
  42. (void) ("The value of x is %d\n", x);
  43.  
  44. ...in which case I still get the warning.
  45.  
  46. I guess (ugh) I could fall back to using Dbg(("printf args %d,%d,%d",x,y,z)),
  47. but I really don't want to!
  48.